package com.starlight.flower_server.infrastructure.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.starlight.flower_server.domain.TotalData;
import com.starlight.flower_server.infrastructure.entity.Order;
import com.starlight.flower_server.infrastructure.entity.Role;
import com.starlight.flower_server.infrastructure.mapper.RoleMapper;
import com.starlight.flower_server.infrastructure.repository.RoleRepository;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author yfy2001
 * @date 2023/4/18 21:18
 */
@Repository
public class RoleRepositoryImpl implements RoleRepository {
    @Resource
    private RoleMapper roleMapper;

    @Override
    public Map<Long, Role> queryMap() {
        List<Role> list=roleMapper.selectList(new LambdaQueryWrapper<Role>()
                .isNotNull(Role::getId));
        return list.stream().collect(Collectors.toMap(Role::getId, v->v,(v1, v2)->v2));
    }

    @Override
    public List<Role> queryAll() {
        return roleMapper.selectList(new LambdaQueryWrapper<Role>()
                .isNotNull(Role::getId));
    }
}
